package com.jeecg.p3.commonluckymoney.web;

import com.jeecg.p3.baseApi.service.BaseApiJwidService;
import com.jeecg.p3.baseApi.service.BaseApiSystemService;
import com.jeecg.p3.baseApi.util.EmojiFilter;
import com.jeecg.p3.baseApi.util.WeixinUserUtil;
import com.jeecg.p3.commonluckymoney.def.CommonluckymoneyProperties;
import com.jeecg.p3.commonluckymoney.entity.WxActCommonluckymoney;
import com.jeecg.p3.commonluckymoney.entity.WxActCommonluckymoneyAwards;
import com.jeecg.p3.commonluckymoney.entity.WxActCommonluckymoneyRecord;
import com.jeecg.p3.commonluckymoney.entity.WxActCommonluckymoneyRegistration;
import com.jeecg.p3.commonluckymoney.exception.CommonluckymoneyException;
import com.jeecg.p3.commonluckymoney.exception.CommonluckymoneyExceptionEnum;
import com.jeecg.p3.commonluckymoney.service.WxActCommonluckymoneyAwardsService;
import com.jeecg.p3.commonluckymoney.service.WxActCommonluckymoneyRecordService;
import com.jeecg.p3.commonluckymoney.service.WxActCommonluckymoneyRegistrationService;
import com.jeecg.p3.commonluckymoney.service.WxActCommonluckymoneyService;
import org.apache.velocity.VelocityContext;
import org.jeecgframework.p3.base.vo.WeixinDto;
import org.jeecgframework.p3.core.common.utils.AjaxJson;
import org.jeecgframework.p3.core.common.utils.DateUtil;
import org.jeecgframework.p3.core.common.utils.RandomUtils;
import org.jeecgframework.p3.core.util.WeiXinHttpUtil;
import org.jeecgframework.p3.core.util.plugin.ViewVelocity;
import org.jeecgframework.p3.core.utils.common.StringUtils;
import org.jeecgframework.p3.core.web.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/commonluckymoney")
public class CommonluckymoneyCoController extends BaseController {
	public final static Logger LOG = LoggerFactory.getLogger(CommonluckymoneyCoController.class);
	@Autowired
	private WxActCommonluckymoneyService commonluckymoneyService;
	@Autowired
	private WxActCommonluckymoneyRegistrationService commonluckymoneyRegistrationService;
	@Autowired
	private WxActCommonluckymoneyAwardsService commonluckymoneyAwardsService;
	@Autowired
	private WxActCommonluckymoneyRecordService commonluckymoneyRecordService;
	@Autowired
	private BaseApiJwidService baseApiJwidService;
	@Autowired
	private BaseApiSystemService baseApiSystemService;
	private static String domain = CommonluckymoneyProperties.domain;
	/**
	 * 跳转到活动首页
	 * 
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/toIndex", method = { RequestMethod.GET,RequestMethod.POST })
	public void toIndex(@ModelAttribute WeixinDto weixinDto,HttpServletRequest request, HttpServletResponse response)throws Exception {
		LOG.info("toIndex parameter WeixinDto={}.",new Object[] { weixinDto });
		// 装载微信所需参数
		String jwid = weixinDto.getJwid();
		String appid = weixinDto.getAppid();
		String actId = weixinDto.getActId();
		VelocityContext velocityContext = new VelocityContext();
		String viewName = "commonluckymoney/co/vm/index.vm";
		WxActCommonluckymoney commonluckymoney = null;
		try {
			// 参数验证
			validateBargainDtoParam(weixinDto);
			WeixinUserUtil.setWeixinDto(weixinDto,null);
			if (weixinDto.getOpenid() != null) {
				// 得到昵称并进行过滤
				weixinDto.setNickname(EmojiFilter.filterEmoji(weixinDto.getNickname()));
			}
			// 获取活动信息
			commonluckymoney = commonluckymoneyService.queryById(actId);
			if(commonluckymoney==null){
				throw new CommonluckymoneyException(CommonluckymoneyExceptionEnum.ARGUMENT_ERROR,"活动不存在");
			}
			// 获取活动信息
			if ("0".equals(commonluckymoney.getActiveFlag())) {
				throw new CommonluckymoneyException(CommonluckymoneyExceptionEnum.ACT_BARGAIN_NO_START,"活动未开始，请等待！");
			}
			
			//判断活动是否关注可参加  0不关注可参加 1关注可参加
			if("1".equals(commonluckymoney.getFoucsUserCanJoin())){
				//判断用户是否关注
				if(!"1".equals(weixinDto.getSubscribe())){
					String qrcodeUrl = baseApiJwidService.getQrcodeUrl(jwid);
					velocityContext.put("qrcodeUrl", qrcodeUrl);
					velocityContext.put("notSubscribe", "true");
				}
			}
			//update-begin--Author:zhaofei  Date: 20190820 for：拆红包经典模板设置Subscribe值
			if("0".equals(commonluckymoney.getFoucsUserCanJoin())){
				weixinDto.setSubscribe("1");
			}
			//update-begin--Author:zhaofei  Date: 20190820 for：拆红包经典模板设置Subscribe值
			commonluckymoney.setPageView(commonluckymoney.getPageView() + 1);
			commonluckymoneyService.update(commonluckymoney);
			velocityContext.put("weixinDto", weixinDto);
			velocityContext.put("commonluckymoney", commonluckymoney);
			String url = request.getRequestURL() + "?"+ request.getQueryString();
			if (url.indexOf("#") != -1) {
				url = url.substring(0, url.indexOf("#"));
			}
			
			if(StringUtils.isNotEmpty(commonluckymoney.getTemplate())){
				viewName = "commonluckymoney/"+commonluckymoney.getTemplate()+"/vm/index.vm";
			}
			WxActCommonluckymoneyRecord record = commonluckymoneyRecordService.queryRecordByActIdAndOpenid(actId,weixinDto.getOpenid());
			if(record!=null){
				velocityContext.put("record", record);
			}
			WxActCommonluckymoneyRegistration commonluckymoneyRegistration = commonluckymoneyRegistrationService.queryRegistrationByActIdAndOpenid(actId,weixinDto.getOpenid());
			if(commonluckymoneyRegistration!=null){
				velocityContext.put("commonluckymoneyRegistration", commonluckymoneyRegistration);
			}
			String qrcodeUrl = baseApiJwidService.getQrcodeUrl(weixinDto.getJwid());
			velocityContext.put("qrcodeUrl", qrcodeUrl);
			System.out.println("--------------当前访问PageUrl---------------："+ url);
			velocityContext.put("nonceStr", WeiXinHttpUtil.nonceStr);
			velocityContext.put("timestamp", WeiXinHttpUtil.timestamp);
			String Hdurl = commonluckymoney.getHdurl().replace("${domain}",domain);
			velocityContext.put("hdUrl",Hdurl); //获取分享URL
			velocityContext.put("appId", appid);
			//velocityContext.put("signature",WeiXinHttpUtil.getRedisSignature(request, jwid));
			//update-begin--Author:zhangweijian  Date: 20180314 for：底部logo修改
			velocityContext.put("huodong_bottom_copyright", baseApiSystemService.getHuodongLogoBottomCopyright(commonluckymoney.getCreateBy()));
			Date currDate = new Date();
			if (currDate.before(commonluckymoney.getBegainTime())) {
				String begainTime = DateUtil.date2Str(commonluckymoney.getBegainTime(), "yyyy年MM月dd日");
				throw new CommonluckymoneyException(CommonluckymoneyExceptionEnum.ACT_BARGAIN_NO_START,"活动未开始,开始时间为<br/>" + begainTime + ",请耐心等待！");
			}
			if (currDate.after(commonluckymoney.getEndTime())) {
				throw new CommonluckymoneyException(CommonluckymoneyExceptionEnum.ACT_BARGAIN_END, "活动已结束");
			}
			//update-end--Author:zhangweijian  Date: 20180314 for：底部logo修改
			//update-begin--Author:zhangweijian  Date: 20180316 for：活动开始结束页面
		} catch (CommonluckymoneyException e) {
			e.printStackTrace();
			LOG.error("toIndex error:{}", e.getMessage());
			viewName = "commonluckymoney/"+commonluckymoney.getTemplate()+"/vm/index.vm";
			if(e.getDefineCode().equals(CommonluckymoneyExceptionEnum.ACT_BARGAIN_NO_START.getErrCode())){
				velocityContext.put("act_Status", "false");
				velocityContext.put("act_Status_Msg", "活动未开始");
			}else if(e.getDefineCode().equals(CommonluckymoneyExceptionEnum.ACT_BARGAIN_END.getErrCode())){
				velocityContext.put("act_Status", "false");
				velocityContext.put("act_Status_Msg", "活动已结束");
				//update-end--Author:zhangweijian  Date: 20180316 for：活动开始结束页面
			}else{
				viewName= "system/vm/error.vm";
			}
			velocityContext.put("errCode", e.getDefineCode());
			velocityContext.put("errMsg", e.getMessage());
		} catch (Exception e) {
			e.printStackTrace();
			LOG.error("toIndex error:{}", e);
			viewName= "system/vm/error.vm";
			velocityContext.put("errCode",CommonluckymoneyExceptionEnum.SYS_ERROR.getErrCode());
			velocityContext.put("errMsg",CommonluckymoneyExceptionEnum.SYS_ERROR.getErrChineseMsg());
		}
		ViewVelocity.view(request,response, viewName, velocityContext);
	}

	/**
	 * 刷新访问量
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(value = "/pageView", method = { RequestMethod.GET,RequestMethod.POST })
	public AjaxJson pageView(@ModelAttribute WeixinDto weixinDto,HttpServletRequest request) {
		AjaxJson j = new AjaxJson();
		LOG.info("pageView parameter bargainDto={}.",new Object[] { weixinDto });
		try {
			// 获取活动信息
			WxActCommonluckymoney commonluckymoney = commonluckymoneyService.queryById(weixinDto.getActId());
			j.setObj(commonluckymoney.getPageView());
			j.setSuccess(true);
		} catch (CommonluckymoneyException e) {
			e.printStackTrace();
			j.setSuccess(false);
			j.setMsg(e.getMessage());
			LOG.error("pageView error:{}", e.getMessage());
		} catch (Exception e) {
			e.printStackTrace();
			j.setSuccess(false);
			j.setMsg("分享失败！");
			LOG.error("pageView error:{}", e.getMessage());
		}
		return j;
	}

	/**
	 * 进入页面执行中奖、领奖状态的不同显示
	 * 
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(value = "/recieveState", method = { RequestMethod.GET,RequestMethod.POST })
	public AjaxJson recieveState(@ModelAttribute WeixinDto weixinDto,HttpServletRequest request) {
		AjaxJson j = new AjaxJson();
		LOG.info("recieveState parameter bargainDto={}.",new Object[] { weixinDto });
		String actId = weixinDto.getActId();
		try {
			Map<String, Object> dataMap = new HashMap<String, Object>();
			// 查询抽奖记录
			WxActCommonluckymoneyRegistration commonluckymoneyRegistration = commonluckymoneyRegistrationService.queryRegistrationByActIdAndOpenid(actId,weixinDto.getOpenid());
			if (commonluckymoneyRegistration == null) { // 没有参与过抽奖
				j.setSuccess(false);
				return j;
			}
			if ("0".equals(commonluckymoneyRegistration.getRecieveStatus())) {
				dataMap.put("luky", false);// 未中奖
			} else {
				dataMap.put("luky", true);// 已中奖
				WxActCommonluckymoneyRecord record = commonluckymoneyRecordService.queryRecordByActIdAndOpenid(actId,weixinDto.getOpenid());
				if ("0".equals(record.getRecieveStatus())) {
					dataMap.put("recieve", false);// 未领奖
				} else {
					dataMap.put("recieve", true);// 已领奖
				}
				j.setObj(record);// 返回中奖记录
			}
			j.setAttributes(dataMap);
			j.setSuccess(true);
		} catch (CommonluckymoneyException e) {
			e.printStackTrace();
			j.setSuccess(false);
			j.setMsg(e.getMessage());
			LOG.error("recieveState error:{}", e.getMessage());
		} catch (Exception e) {
			e.printStackTrace();
			j.setSuccess(false);
			j.setMsg("访问异常！");
			LOG.error("recieveState error:{}", e.getMessage());
		}
		return j;
	}

	/**
	 * 拆红包
	 * 
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/extractAwards", method = { RequestMethod.GET,
			RequestMethod.POST })
	@ResponseBody
	public AjaxJson extractAwards(@ModelAttribute WeixinDto weixinDto,HttpServletRequest request) {
		AjaxJson j = new AjaxJson();
		LOG.info("extractAwards parameter bargainDto={}.",new Object[] { weixinDto });
		String jwid = weixinDto.getJwid();
		String actId = weixinDto.getActId();
		try {
			// 获取活动信息
			WxActCommonluckymoney commonluckymoney = commonluckymoneyService.queryById(actId);
			Map<String, Object> dataMap = new HashMap<String, Object>();
			// 查询抽奖记录
			WxActCommonluckymoneyRegistration commonluckymoneyRegistration = commonluckymoneyRegistrationService.queryRegistrationByActIdAndOpenid(actId,weixinDto.getOpenid());
			if (commonluckymoneyRegistration!= null) {//已经参加过抽奖
				if ("0".equals(commonluckymoneyRegistration.getRecieveStatus())) {
					dataMap.put("luky", false);// 未中奖
				}else{
					dataMap.put("luky", true);// 已中奖
					WxActCommonluckymoneyRecord record = commonluckymoneyRecordService.queryRecordByActIdAndOpenid(actId,weixinDto.getOpenid());
					if ("0".equals(record.getRecieveStatus())){
						dataMap.put("recieve", false);// 未领奖
					}else{
						dataMap.put("recieve", true);// 已领奖
					}
					j.setObj(record);// 返回中奖记录					
				} 				
			}else{
				// 如果没有参与过抽奖
				commonluckymoneyRegistration = new WxActCommonluckymoneyRegistration();
				// 添加参与抽奖记录
				commonluckymoneyRegistration.setId(RandomUtils.generateID());
				commonluckymoneyRegistration.setActId(actId);
				commonluckymoneyRegistration.setOpenid(weixinDto.getOpenid());
				commonluckymoneyRegistration.setJwid(jwid);
				// 抽奖
				if (!extracPrize(commonluckymoney)) { // 未中奖
					commonluckymoneyRegistration.setRecieveStatus("0");
					WxActCommonluckymoneyRecord record = new WxActCommonluckymoneyRecord();
					record.setId(RandomUtils.generateID());
					record.setActId(actId);
					record.setOpenid(weixinDto.getOpenid());
					record.setAwardsSeq(0);
					record.setRecieveStatus("2");
					record.setRecieveTime(new Date());
					record.setJwid(weixinDto.getJwid());
					//record.setPhone(getBindPhone(weixinDto.getOpenid()));
					commonluckymoneyRecordService.doAdd(record);		
				} else {
					// 根据当前日期和活动id获取奖品
					List<WxActCommonluckymoneyAwards> awardList = commonluckymoneyAwardsService.queryAwardsByActIdAndCurrDate(actId,DateUtil.date2Str(new Date(), "yyyy-MM-dd"));
					if (awardList == null || awardList.size() <= 0) {
						commonluckymoneyRegistration.setRecieveStatus("0");// 未中奖
					} else {
						// 计算抽到的奖品
						WxActCommonluckymoneyAwards award = calcCardPercentage(awardList);
						WxActCommonluckymoneyRecord record = commonluckymoneyRecordService.creatRecord(award, weixinDto);
						if (record == null) {
							commonluckymoneyRegistration.setRecieveStatus("0");// 未中奖
						} else {
							commonluckymoneyRegistration.setRecieveStatus("1");// 已中奖
							j.setObj(record);// 返回中奖记录
						}
					}
				}
				commonluckymoneyRegistrationService.doAdd(commonluckymoneyRegistration);// 保存抽奖记录
				if ("0".equals(commonluckymoneyRegistration.getRecieveStatus())) {
					dataMap.put("luky", false);// 未中奖
				} else {
					dataMap.put("luky", true);// 已中奖
				}
			}			
			j.setAttributes(dataMap);
			j.setSuccess(true);
		} catch (CommonluckymoneyException e) {
			e.printStackTrace();
			j.setSuccess(false);
			j.setMsg(e.getMessage());
			LOG.error("extractAwards error:{}", e.getMessage());
		} catch (Exception e) {
			e.printStackTrace();
			j.setSuccess(false);
			j.setMsg("访问异常！");
			LOG.error("extractAwards error:{}", e.getMessage());
		}
		return j;
	}
	
	/**
	 * 领取奖品
	 * 
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/recieveAwards", method = { RequestMethod.GET,RequestMethod.POST })
	@ResponseBody
	public AjaxJson recieveAwards(@ModelAttribute WeixinDto weixinDto,HttpServletRequest request) {
		AjaxJson j = new AjaxJson();
		LOG.info("recieveAwards parameter bargainDto={}.",new Object[] { weixinDto });
		String actId = weixinDto.getActId();
		try {
			// 获取活动信息
			WxActCommonluckymoney commonluckymoney = commonluckymoneyService.queryById(actId);
			if ("0".equals(commonluckymoney.getActiveFlag())) {
				throw new CommonluckymoneyException(CommonluckymoneyExceptionEnum.ACT_BARGAIN_NO_START,"活动已关闭！");
			}
			Date currDate = new Date();
			if (currDate.after(commonluckymoney.getEndTime())) {
				throw new CommonluckymoneyException(CommonluckymoneyExceptionEnum.ACT_BARGAIN_END, "活动已结束");
			}
		
			WxActCommonluckymoneyRecord record = commonluckymoneyRecordService.queryRecordByActIdAndOpenid(actId,weixinDto.getOpenid());
			record.setRecieveStatus("1");
			record.setPhone(request.getParameter("mobile"));
			commonluckymoneyRecordService.doEdit(record);
			j.setObj(record);// 返回中奖记录
			j.setSuccess(true);
		} catch (CommonluckymoneyException e) {
			e.printStackTrace();
			j.setSuccess(false);
			j.setMsg(e.getMessage());
			LOG.error("recieveAwards error:{}", e.getMessage());
		} catch (Exception e) {
			e.printStackTrace();
			j.setSuccess(false);
			j.setMsg("访问异常！");
			LOG.error("recieveAwards error:{}", e.getMessage());
		}
		return j;
	}
	/**
	 * 领取奖品
	 * 
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/updateMyrecord", method = { RequestMethod.GET,RequestMethod.POST })
	@ResponseBody
	public AjaxJson updateMyrecord(@ModelAttribute WeixinDto weixinDto,HttpServletRequest request) {
		AjaxJson j = new AjaxJson();
		LOG.info("updateMyrecord parameter bargainDto={}.",new Object[] { weixinDto });
		String id = request.getParameter("id");
		String realname = request.getParameter("realname");
		String phone = request.getParameter("phone");
		String address = request.getParameter("address");
		try {
			WxActCommonluckymoneyRecord record =new WxActCommonluckymoneyRecord();
			//commonluckymoneyRecordService.queryById(id)
			//record.setRecieveStatus("1");
			record.setId(id);
			record.setPhone(phone);
			record.setRealname(realname);
			record.setAddress(address);
			commonluckymoneyRecordService.doEdit(record);
			//j.setObj(record);// 返回中奖记录
			//j.setSuccess(true);
		} catch (CommonluckymoneyException e) {
			e.printStackTrace();
			j.setSuccess(false);
			j.setMsg(e.getMessage());
			LOG.error("updateMyrecord error:{}", e.getMessage());
		} catch (Exception e) {
			e.printStackTrace();
			j.setSuccess(false);
			j.setMsg("访问异常！");
			LOG.error("updateMyrecord error:{}", e.getMessage());
		}
		return j;
	}
	/**
	 * 跳转到活动说明页
	 * 
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/detail", method = { RequestMethod.GET,RequestMethod.POST })
	public void detail(@ModelAttribute WeixinDto weixinDto,HttpServletRequest request, HttpServletResponse response)throws Exception {
		// ====================================================================================================
		// 装载微信所需参数
		String jwid = weixinDto.getJwid();
		String appid = weixinDto.getAppid();
		String actId = weixinDto.getActId();
		// ====================================================================================================

		VelocityContext velocityContext;
		String viewName = "commonluckymoney/co/vm/detail.vm";
		velocityContext = new VelocityContext();			
		try {
			// 获取活动信息
			WxActCommonluckymoney commonluckymoney = commonluckymoneyService.queryById(actId);
			velocityContext.put("commonluckymoney", commonluckymoney);
			velocityContext.put("weixinDto", weixinDto);
			String url = request.getRequestURL() + "?" + request.getQueryString();																				// "@");
			if (url.indexOf("#") != -1) {
				url = url.substring(0, url.indexOf("#"));
			}
			if(StringUtils.isNotEmpty(commonluckymoney.getTemplate())){
				viewName = "commonluckymoney/"+commonluckymoney.getTemplate()+"/vm/detail.vm";
			}
			// ------微信分享参数-------
			velocityContext.put("nonceStr", WeiXinHttpUtil.nonceStr);
			velocityContext.put("timestamp", WeiXinHttpUtil.timestamp);
			String Hdurl = commonluckymoney.getHdurl().replace("${domain}",domain);
			velocityContext.put("hdUrl",Hdurl); //获取分享URL
			velocityContext.put("appId", appid);
			velocityContext.put("signature",WeiXinHttpUtil.getRedisSignature(request, jwid));
		} catch (CommonluckymoneyException e) {
			e.printStackTrace();
			LOG.error("toIndex error:{}", e.getMessage());
			viewName= "system/vm/error.vm";
			velocityContext.put("errCode", e.getDefineCode());
			velocityContext.put("errMsg", e.getMessage());
		} catch (Exception e) {
			e.printStackTrace();
			LOG.error("toIndex error:{}", e);
			viewName= "system/vm/error.vm";
			velocityContext.put("errCode",CommonluckymoneyExceptionEnum.SYS_ERROR.getErrCode());
			velocityContext.put("errMsg",CommonluckymoneyExceptionEnum.SYS_ERROR.getErrChineseMsg());
		}
		// ------微信分享参数-------
		ViewVelocity.view(request,response, viewName, velocityContext);
	}

	// 计算抽到的奖品
	private WxActCommonluckymoneyAwards calcCardPercentage(List<WxActCommonluckymoneyAwards> awardList) {
		double randomNumber = Math.random();
		int index = 0;
		double minRate = 0;
		double maxRate = 0;
		WxActCommonluckymoneyAwards award = null;
		int remaindTotalNum = getRemaindTotalNum(awardList);
		for (int i = 0; i < awardList.size(); i++) {
			award = awardList.get(i);
			maxRate += getRate(award.getRemainNum(), remaindTotalNum);
			if (randomNumber >= minRate && randomNumber <= maxRate) {
				index = i;
				break;
			} else {
				minRate += getRate(award.getRemainNum(), remaindTotalNum);
			}
		}
		return awardList.get(index);
	}

	private int getRemaindTotalNum(List<WxActCommonluckymoneyAwards> awardList) {
		int total = 0;
		for (WxActCommonluckymoneyAwards award : awardList) {
			total += award.getRemainNum();
		}
		return total;
	}

	private double getRate(int cardRemainNum, int remaindTotalNum) {
		double rate = 0;
		rate = cardRemainNum * 1.00 / remaindTotalNum;
		return rate;
	}

	private Boolean extracPrize(WxActCommonluckymoney commonluckymoney) {
		double randomNumber = Math.random();
		double minRate = 0;
		double maxRate = 0;
		double rate = Double.valueOf(commonluckymoney.getProbability());
		maxRate += rate;
		if (randomNumber >= minRate && randomNumber <= maxRate) {
			return true;
		} else {
			return false;
		}
	}

	private void validateBargainDtoParam(WeixinDto weixinDto) {
		if (StringUtils.isEmpty(weixinDto.getActId())) {
			throw new CommonluckymoneyException(CommonluckymoneyExceptionEnum.ARGUMENT_ERROR, "活动ID不能为空");
		}
		if (StringUtils.isEmpty(weixinDto.getOpenid())) {
			throw new CommonluckymoneyException(CommonluckymoneyExceptionEnum.ARGUMENT_ERROR,"参与人openid不能为空");
		}
	}

}
